package com.link.base.task;

import com.link.base.core.basic.config.xxljob.BaseLinkJobHandler;
import com.link.base.wechat.wxtoken.service.WxTokenService;
import com.xxl.job.core.biz.model.ReturnT;
import com.xxl.job.core.handler.annotation.JobHandler;
import com.xxl.job.core.log.XxlJobLogger;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;

/**
 * 微信工作流服务 -- 定时刷新所有公众号的access_token
 * 
 * @author ouyangzhenqiang
 * @date 2019/02/27 18:26
 */
@JobHandler(value = "TaskRefreshAllWxToken")
@Component
public class TaskRefreshAllWxToken extends BaseLinkJobHandler {
    @Resource
    private WxTokenService wxTokenService;

    @Override
    public ReturnT<String> execute(String strings) throws Exception {
        try {
            XxlJobLogger.log("XXL-JOB, refresh all wx access_token...");
            wxTokenService.refreshAllWxToken();
            return ReturnT.SUCCESS;
        } catch (Exception e) {
            XxlJobLogger.log(e.getMessage());
            return ReturnT.FAIL;
        }
    }
}
